﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace TeamTasker.Client.Presentation.Controls.CustomTabControl
{
    [TemplatePart(Name = "CloseButton_PART", Type = typeof (Button))]
    public class CustomTabControl : TabControl
    {
        public CustomTabControl()
        {
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseTab));
        }

        private void CloseTab(object sender, ExecutedRoutedEventArgs e)
        {
            var tab = e.Source as TabItem;
            Items.Remove(tab);
        }
    }
}